package ling.common.domain.entity;

import com.easy.query.core.annotation.Column;
import com.easy.query.core.annotation.ColumnIgnore;
import com.easy.query.core.annotation.EasyWhereCondition;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.AccessLevel;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Data
public abstract class CreatedEntity<T extends Comparable<T> & Serializable>  implements IdEntity<T> , ICreatedEntity<Long>{


    @Data
    public static class LongId extends CreatedEntity<Long> implements IExtendInfo {

        @Getter(AccessLevel.NONE)
        @Setter(AccessLevel.NONE)
        @ColumnIgnore
        HashMap<String, Object> extendMap=new HashMap<>();

        public Map<String,Object> getExtendMap(){
            return extendMap;
        }


        @EasyWhereCondition(type = EasyWhereCondition.Condition.EQUAL)
        @Column(primaryKey = true, generatedKey = true)
        Long id;

    }

    /**
     * 创建者
     */
    @ApiModelProperty("创建人id")
    private Long createdId;

    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createdTime = new Date();
}
